#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/3/17 0017 14:00
# @Author : Moyan# @Site : 
# @File : test.py
# @Software: PyCharm
import requests
import re

# url = "https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E6%89%8B%E6%9C%BA%E5%A3%81%E7%BA%B8%E5%A4%A7%E5%85%A8&hs=2&pn=12&spn=0&di=100320&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&ie=utf-8&oe=utf-8&cl=2&lm=-1&cs=2023455215%2C2932304243&os=4183302863%2C3766565846&simid=4058862095%2C571921139&adpicid=0&lpn=0&ln=30&fr=ala&fm=&sme=&cg=&bdtype=0&oriquery=%E6%89%8B%E6%9C%BA%E5%A3%81%E7%BA%B8%E5%A4%A7%E5%85%A8&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201510%2F02%2F201510021332"
url = "https://www.mzitu.com/zipai/comment-page-352/"
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
    }
r = requests.get(url=url, headers=headers).text
# urls = '.*?src="(.*?)'
# pattern = re.compile(r'.*class="currentImg"')
imglist = re.findall('src="(.*?)"',r,re.S)
# imglist = re.findall(r, re.S)
n = 0
for img in imglist:
    print(img)
    filename = str(n) + '.png'
    imgpage = requests.get(url=img, headers=headers).content
    with open(filename, "wb")as f:
        f.write(imgpage)
    print("下载中")
    n += 1
exit()
